<!-- 确认订单 -->
<template>
	<view class="order-wrap">
		<shopro-login-modal></shopro-login-modal>
		<!-- 地址栏 -->
		<view class="head_box" @tap="jump('/pages/prefile/address/list', { from: 'order' })">
			<view class="add-address-box u-flex u-flex-1" v-if="Object.keys(addressData).length === 0">
				<view class="box-bg u-p-30 u-flex-1 u-flex u-row-between">
					<text class="select-notice">请选择收货地址</text>
					<text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf;"></text>
				</view>
			</view>
			<view class="add-address-box u-p-30" v-else>
				<view class="top u-flex">
					<text class="name">{{ addressData.username }}</text>
					<text class="phone">{{ addressData.mobile }}</text>
					<text class="tag" v-show="addressData.isdefault == 1">默认</text>
				</view>
				<view class="detail u-flex u-row-between">
					<view class="address">
						{{ addressData.province }}{{ addressData.city }}{{ addressData.district }}
					</view>
					<text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf;"></text>
				</view>
			</view>
		</view>

		<view class="u-m-b-10">
			<!-- 确认订单商品卡片 -->
			<view class="goods-list" v-for="g in orderPre.orders[0]['order_goods']" :key="g.order_sn">
				<view class="goods-card u-p-30">
					<shopro-mini-card :title="g.title" :image="g.thumb">
						<template #describe>
							<view class="order-sku u-ellipsis-1">
								<text class="order-num">
									{{ g.detail.current_sku_price && g.detail.current_sku_price.goods_sku_text ? g.detail.current_sku_price.goods_sku_text : '' }}
								</text>
							</view>
						</template>
						<template #cardBottom>
							<view class="goods-price u-flex  u-row-between">
								<view class="">
									<text>￥{{ g.price }}</text>
								</view>
								<text class="goods-num">x1</text>
							</view>
						</template>
					</shopro-mini-card>
				</view>

				<!-- 配送方式 -->
				<!-- <view class="logistic item-list u-flex u-row-between" @tap="onSelExpressType(g)">
					<view class="item-title">配送方式</view>
					<view class="u-flex">
						<view class="detail">{{ getCurGoodsExpress(g) }}</view>
						<text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf;"></text>
					</view>
				</view> -->
			</view>

			
				<!-- 备注 -->
				<!-- <view class="remark-box u-flex item-list u-p-30">
					<view class="item-title">备注</view>
					<input class="item-input " placeholder-class="input-pl" type="text" v-model="remark"
						placeholder="建议留言前先于卖家沟通确认" />
				</view> -->

				<!-- 选择优惠券 -->
				<!-- <sh-select-coupon v-if="hasCoupons" :couponList="couponList" @change="selectCoupon"></sh-select-coupon> -->

				<!-- 积分 -->
				<!-- <view class="score item-list u-flex u-row-between" v-show="orderType === 'score'">
					<view class="u-flex"><text class="item-title">积分</text></view>
					<view class="price">-{{ orderPre.score_amount || 0 }}积分</view>
				</view> -->
				<!-- 金额明细 -->
				<view class=" u-flex u-row-between item-list border-top u-m-b-10">
					<view class="item-title">商品金额</view>
					<view class="u-flex">
						<text class="price">￥{{ orderPre.total_price || '0.00' }}</text>
					</view>
				</view>

				<!-- 活动优惠 -->
				<!-- <u-collapse
					v-if="orderPre.activity_discount_infos && orderPre.activity_discount_infos.length && Number(orderPre.activity_discount_money)"
					event-type="close" :arrow="true" :accordion="true" arrowColor="#bfbfbf"
					:head-style="{ background: '#fff', height: '100rpx' }">
					<u-collapse-item>
						<block slot="title">
							<view style="width: 680rpx;padding-right: 0;" class="u-flex u-row-between item-list">
								<view class="item-title">活动优惠</view>
								<view class="u-flex">
									<text class="price"
										style="margin-right: 0;">-￥{{ orderPre.activity_discount_money || '0.00' }}</text>
								</view>
							</view>
						</block>
						<view class="" v-for="item in orderPre.activity_discount_infos" :key="item.activity_id">
							<view class="u-flex u-row-between item-list" v-if="item.activity_type !== 'free_shipping'">
								<view class="item-title">{{ item.activity_title }}</view>
								<view class="u-flex">
									<text class="price"
										style="color: #666;">-￥{{ item.activity_discount_money || '0.00' }}</text>
								</view>
							</view>
						</view>
					</u-collapse-item>
				</u-collapse> -->
				<view class="price-box  u-flex u-row-between item-list">
					<view class="item-title u-flex u-col-center">
						<view class="u-m-r-10">运费</view>
						<!-- <view class="activity-title" v-if="Number(orderPre.dispatch_discount_money) > 0">活动减￥
							{{ orderPre.dispatch_discount_money }}
						</view> -->
					</view>
					<view class="u-flex">
					<!-- 	<text class="origin-price u-m-r-10"
							v-if="Number(orderPre.dispatch_discount_money) > 0">-￥{{ orderPre.dispatch_amount }}</text> -->
						<text
							class="price">￥{{ orderPre.total_dispatch_price || '0.00' }}</text>
					</view>
				</view>
			
		</view>

		<!-- 底部 -->

		<view class="foot-box-wrap">
			
			<view class="foot-box u-flex u-row-between safe-area-inset-bottom">
				<view
					style="width: 750upx;height: 61upx;background: #FFF5E4; padding: 13upx 26upx; position: fixed;bottom: 100upx; margin-left: -24upx;">
					<image style="width: 33upx; height: 33upx; vertical-align: middle;"
						src="../../../static/images/index/zhuyi.png"></image>
					<text style="font-size: 22upx; color: #D3A24F; margin-left: 10upx;">该商品为活动商品，购买后不支持退货退款 </text>
				</view>
				<view class="u-flex" style="flex: 1;">
					<!-- <text class="num">共{{ totalNum }}件</text> -->
					<view class="all-money">
						<text>合计：</text>
						<text class="price">￥{{ orderPre.amount_items[0]['amount'] || '0.00' }}</text>
					</view>
				</view>
				<button class="cu-btn sub-btn" @tap="subOrder" :disabled="isDisabled"
					hover-class="btn-hover">提交订单</button>
			</view>
		</view>
		<!-- {{tixinshow}} -->
		<!-- 提示 -->
		<u-mask :show="tixinMaskshow" @click="tixinMaskshow = false">
			<view class="tixinwarp">
				<view class="tixinrect" @tap.stop>
					<view class="title-image">
						<image src="../../../static/images/index/tixin.png" style="width: 218upx; height: 217upx;">
						</image>
					</view>
					<view class="tips">
						<view class="line left-line"></view>
						<view class="title">温馨提示</view>
						<view class="line right-line"></view>
					</view>
					<view class="tishi-content">
						该商品为商家推广活动的现金补贴商品，
						拼团成功领取补贴 后不支持退货退款，
						购买时请谨慎选择
					</view>
					<view class="cancel-btn" @tap="tixinMaskshow = false">我已了解</view>
				</view>
			</view>
		</u-mask>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tixinMaskshow: true, // 提醒遮罩层
				orderPre: {},
				// platform: this.$platform.get(),
				totalNum: 0,
				couponList: [], //优惠券列表
				addressData: {}, //收货地址
				addressId: 0, //收货地址ID
				customStyle: {
					//自定义按钮样式
					width: '210rpx',
					lineHeight: '70rpx',
					background: 'linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1))',
					boxShadow: ' 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22)',
					borderRadius: '100rpx',
					fontSize: '28rpx',
					border: 'none',
					color: '#fff',
					margin: '0'
				},
				isDisabled: false, //提交
				showCheckTime: false, //配送时间弹窗。
				checkTime: {}, //配送时间数据
				showExpressType: false, //配送方式弹窗
				expressTypeMap: {
					express: '物流快递',
					selfetch: '到店/自提',
					store: '商家配送',
					autosend: '自动发货'
				},

				expressType: [
					//配送方式
					{
						id: 'e1',
						title: '物流快递',
						value: 'express'
					},
					{
						id: 'e2',
						title: '到店/自提',
						value: 'selfetch'
					},
					{
						id: 'e3',
						title: '商家配送',
						value: 'store'
					},
					{
						id: 'e4',
						title: '自动发货',
						value: 'autosend'
					}
				],
				storeList: [], //门店列表
				storeInfo: {
					id: 0,
					name: '',
					dispatch_text: ''
				}, //自提点商家信息
				from: '',
				orderType: '',
				grouponBuyType: 'alone',
				grouponId: 0,
				goodsList: [], //传递过来的参数
				perGoodsList: {}, //确认单订单商品
				currentGoodsId: 0, //当前商品id.
				currentSkuId: 0, //商品的规格ID
				remark: '',
				couponId: 0,
				couponPrice: '选择优惠券',
				expressTypeCur: '',
				inExpressType: [], //当前商品支持的配送方式。
				isProtocol: true, //自提协议。
				selfPhone: '', //编辑手机号
				getFocus: false, //获取焦点。
				checkType: '自提',
				checkTimeCur: 0, //默认选中时间。
				checkTimeId: 'c1', //锚点用
				checkDayCur: 0, //默认日期
				lat: 0, //地理位置
				lng: 0,
				oneOrderPrams: {
					i: 3,
					uuid: 0,
					mid: 107,
					type: 5,
					shop_id: "",
					route: "plugin.fight-groups.frontend.controllers.team.pre-join-team",
					goods_id: 475,
					total: 1,
					option_id: "",
					member_coupon_ids: "",
					orders: [],
					dispatch_type_id: 1,
					mark: 0,
					team_id: 557,
					option_level_id: 158,
					address: {
						"id": 4,
						"username": "廖希程",
						"mobile": "18566126136",
						"zipcode": "",
						"province": "天津",
						"city": "天津市",
						"district": "河东区",
						"address": "test",
						"isdefault": 0,
						"province_id": 120000,
						"city_id": 120100,
						"district_id": 120102
					}
				}
			}
		},
		computed: {
			// ...mapState({
			// 	storeTcp: ({
			// 		shopro
			// 	}) => shopro?.config?.store
			// }),
			expressClass() {
				let cl = 'head-nav--active';
				const {
					expressType,
					expressTypeCur
				} = this;
				if (expressTypeCur === 0) {
					cl = 'head-nav__left--active';
				}
				if (expressTypeCur === expressType.length - 1) {
					cl = 'head-nav__right--active';
				}
				return cl;
			},
			// 是否可以使用优惠券
			hasCoupons() {
				// if (this.couponList.length && !this.orderPre.activity_type) {
				// 	return true;
				// }
				// return Boolean(
				// 	this.couponList.length &&
				// 	this.orderPre.activity_type &&
				// 	this.orderPre.activity_type.indexOf('groupon') === -1 &&
				// 	this.orderPre.activity_type.indexOf('seckill') === -1 &&
				// 	this.orderType !== 'score'
				// );
			}
		},
		onShow() {
			// 监听选择自提点
			uni.$once('SELECT_STORE', res => {
				this.storeInfo = JSON.parse(res.storeInfo);
			});
			// 监听地址
			uni.$on('SELECT_ADDRESS', res => {
				if (res.addressData) {
					this.addressData = JSON.parse(res.addressData);
					this.addressId = this.addressData.id;
				} else {
					this.addressId = 0;
				}
				// this.getPre();
				res.addressData && uni.$off('SELECT_ADDRESS');
			});
		},
		async onLoad() {
			let prams = {
				"goodsList": [{
					"goods_id": 21,
					"goods_num": 1,
					"sku_price_id": 93,
					"goods_price": "23.00"
				}],
				"from": "goods",
				"orderType": "goods",
				"grouponBuyType": "alone",
				"grouponId": 0
			}
			this.oneOrderPrams.mid = this.$Route.query.mid;
			this.oneOrderPrams.goods_id = this.$Route.query.goods_id;
			this.oneOrderPrams.team_id = this.$Route.query.team_id;
			this.oneOrderPrams.option_level_id = this.$Route.query.option_level_id;


			// this.goodsList = prams.goodsList;
			// this.from = prams.from;
			// this.orderType = prams.orderType;
			// this.grouponBuyType = prams.grouponBuyType;
			// this.grouponId = prams.grouponId;
			await this.init();
		},
		methods: {
			// ...mapActions(['getCartList']),
			init() {
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				return Promise.all([this.getDefaultAddress(), this.initDate(), this.oneOrderAction()]).then(() => {
					uni.hideLoading();
				});
			},
			jump(path, parmas) {
				this.$Router.push({
					path: path,
					query: parmas
				});
			},

			// 格式化选择时间
			initDate() {
				let week = {
					0: '周日',
					1: '周一',
					2: '周二',
					3: '周三',
					4: '周四',
					5: '周五',
					6: '周六'
				};
				let now = new Date().getTime();
				let today = this.$u.timeFormat(now);
				let tomorrow = this.$u.timeFormat(now + 86400000);
				let aftertomorrow = this.$u.timeFormat(now + 172800000);
				let week1 = week[new Date().getDay()];
				let week2 = week[new Date(now + 86400000).getDay()];
				let week3 = week[new Date(now + 172800000).getDay()];
				let obj = {
					day: [{
							title: '今天（' + week1 + '）',
							value: today
						},
						{
							title: '明天（' + week2 + '）',
							value: tomorrow
						},
						{
							title: '后天（' + week3 + '）',
							value: aftertomorrow
						}
					],
					time: ['08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00',
						'18:00', '19:00'
					]
				};
				this.checkTime = obj;
			},

			// 格式日期
			check(type, index) {
				if (type == 'time') {
					this.checkTimeCur = index;
					this.checkTimeId = this.checkTime['time'][index].split(':')[[0]];
				}
				if (type == 'day') {
					this.checkDayCur = index;
				}
			},

			// 获取当前商品配送方式
			getCurGoodsExpress(goods) {
				for (let item of this.goodsList) {
					if (item.goods_id == goods.goods_id && goods.sku_price_id == item.sku_price_id) {
						return this.expressTypeMap[item.dispatch_type];
					}
				}
			},

			// 获取位置
			async getLocation() {
				let authState = await new Auth('userLocation').check();
				// #ifdef MP ||　APP-VUE
				authState &&
					uni.getLocation({
						type: 'gcj02',
						success: res => {
							this.lng = res.longitude;
							this.lat = res.latitude;
							this.getStoreAddress();
						},
						fail: err => {
							console.log('确认订单自提位置：', err);
						}
					});
				// #endif
				// #ifdef H5
				uni.getLocation({
					type: 'gcj02',
					success: res => {
						this.lng = res.longitude;
						this.lat = res.latitude;
						this.getStoreAddress();
					}
				});
				// #endif
			},
			// 获取商品支持的自提点。
			getStoreAddress() {
				let that = this;
				that.$http('goods.storeAddress', {
					id: that.currentGoodsId,
					latitude: that.lat,
					longitude: that.lng
				}).then(res => {
					if (res.code == 1) {
						that.storeInfo = res.data.data[0];
						that.storeList = res.data.data;
					}
				});
			},
			// 订单信息
			getPre() {
				let that = this;
				let res = {
					data: {
						"goods_original_amount": "40.00",
						"goods_amount": "23.00",
						"origin_dispatch_amount": "0.00",
						"dispatch_amount": "0.00",
						"total_amount": "23.00",
						"total_fee": "23.00",
						"discount_fee": "0.00",
						"coupon_fee": "0.00",
						"activity_discount_money": "0.00",
						"dispatch_discount_money": "0.00",
						"activity_type": "",
						"score_amount": 0,
						"new_goods_list": [{
							"goods_id": "21",
							"goods_num": 1,
							"sku_price_id": "93",
							"goods_price": "23.00",
							"dispatch_type": "express",
							"detail": {
								"id": 21,
								"type": "normal",
								"title": "北欧抱枕靠垫沙发靠垫办公室腰靠枕床头靠背垫",
								"subtitle": "天鹅绒抱枕套不含芯",
								"weigh": 0,
								"category_ids": "65",
								"image": "http://file.shopro.top/uploads/20210519/e47015df4dcd94479b26e475f221179b.jpeg",
								"images": [
									"http://file.shopro.top/uploads/20210519/e47015df4dcd94479b26e475f221179b.jpeg",
									"http://file.shopro.top/uploads/20210519/2848bf9593187f7f5d5c405497ac38b1.jpeg",
									"http://file.shopro.top/uploads/20210519/4c694a815b06a0d297e4a6b193da67f1.jpeg"
								],
								"params": [{
									"title": "品牌: ",
									"content": "莫吻"
								}, {
									"title": "风格: ",
									"content": "简约现代"
								}, {
									"title": "外套材质: ",
									"content": "毛绒"
								}],
								"content": "<img src=\"http://file.shopro.top/uploads/20210519/5c788f900a5fdd62403dacd614f507c6.jpeg\" alt=\"\" /><img src=\"http://file.shopro.top/uploads/20210519/80adf5dab330cc4e6b8a50cfc22020ef.jpeg\" alt=\"\" />",
								"price": "23",
								"original_price": "40.00",
								"is_sku": 1,
								"likes": 0,
								"views": 44641,
								"sales": 37,
								"show_sales": 0,
								"service_ids": "4,3,2",
								"dispatch_type": "express",
								"dispatch_ids": "1",
								"deletetime": null,
								"activity": null,
								"activity_type": null,
								"buyers": [],
								"sku_price": [{
									"id": 92,
									"goods_sku_ids": "81",
									"goods_id": 21,
									"weigh": 0,
									"image": "http://file.shopro.top/uploads/20210519/4c694a815b06a0d297e4a6b193da67f1.jpeg",
									"stock": 110421,
									"stock_warning": null,
									"sales": 19,
									"sn": "",
									"weight": 0,
									"price": "23.00",
									"goods_sku_text": "松石绿",
									"status": "up",
									"goods_sku_id_arr": ["81"]
								}, {
									"id": 93,
									"goods_sku_ids": "82",
									"goods_id": 21,
									"weigh": 0,
									"image": "http://file.shopro.top/uploads/20210519/2848bf9593187f7f5d5c405497ac38b1.jpeg",
									"stock": 110422,
									"stock_warning": null,
									"sales": 18,
									"sn": "",
									"weight": 0,
									"price": "23.00",
									"goods_sku_text": "橙黄",
									"status": "up",
									"goods_sku_id_arr": ["82"]
								}],
								"stock": 220843,
								"activity_discounts": [],
								"activity_discounts_types": "",
								"activity_discounts_tags": [],
								"current_sku_price": {
									"id": 93,
									"goods_sku_ids": "82",
									"goods_id": 21,
									"weigh": 0,
									"image": "http://file.shopro.top/uploads/20210519/2848bf9593187f7f5d5c405497ac38b1.jpeg",
									"stock": 110422,
									"stock_warning": null,
									"sales": 18,
									"sn": "",
									"weight": 0,
									"price": "23.00",
									"goods_sku_text": "橙黄",
									"status": "up",
									"goods_sku_id_arr": ["82"]
								},
								"favorite": null,
								"dispatch_type_arr": ["express"],
								"service": [{
									"id": 4,
									"name": "极速退款",
									"image": "http://file.shopro.top/uploads/20210524/57d971eb5984317ee794e531ea0f9207.png",
									"description": "超快无审核退款流程"
								}, {
									"id": 3,
									"name": "退货保障",
									"image": "http://file.shopro.top/uploads/20210524/c7e0b30e543aef9e2a801539228fc972.png",
									"description": "卖家投保退货运费险"
								}, {
									"id": 2,
									"name": "七天退换",
									"image": "http://file.shopro.top/uploads/20210524/73d9b9857972e18b70c4f9aa0cb3cbe1.png",
									"description": "满足相应条件(吊牌缺失，洗涤后不支持)时，消费者可申请“七天无理由退货”"
								}],
								"sku": [{
									"id": 80,
									"name": "颜色",
									"pid": 0,
									"goods_id": 21,
									"weigh": 0,
									"content": [{
										"id": 81,
										"name": "松石绿",
										"pid": 80,
										"goods_id": 21,
										"weigh": 0
									}, {
										"id": 82,
										"name": "橙黄",
										"pid": 80,
										"goods_id": 21,
										"weigh": 0
									}]
								}],
								"coupons": [{
									"id": 10,
									"name": "vcrw",
									"type": "cash",
									"goods_ids": "113,110,109,108,106,104,99,47,32,31,30,28,26,25,24,23,22,21,20,19",
									"amount": "300.00",
									"enough": "500.00",
									"stock": 74,
									"limit": 1,
									"gettime": {
										"start": 1634745600,
										"end": 1638201600
									},
									"usetime": {
										"start": 1634745600,
										"end": 1638201600
									},
									"description": "",
									"usetimestart": 1634745600,
									"usetimeend": 1638201600,
									"gettimestart": 1634745600,
									"gettimeend": 1638201600
								}, {
									"id": 11,
									"name": "测试优惠券",
									"type": "cash",
									"goods_ids": "0",
									"amount": "99.00",
									"enough": "100.00",
									"stock": 73,
									"limit": 1,
									"gettime": {
										"start": 1634832000,
										"end": 1635609600
									},
									"usetime": {
										"start": 1634832000,
										"end": 1638201600
									},
									"description": "测试优惠券描述",
									"usetimestart": 1634832000,
									"usetimeend": 1638201600,
									"gettimestart": 1634832000,
									"gettimeend": 1635609600
								}]
							},
							"goods_original_amount": "40.00",
							"goods_amount": "23.00",
							"dispatch_amount": "0.00",
							"score_amount": 0,
							"dispatch_id": 1,
							"store_id": 0,
							"activity_type": "",
							"discount_fee": "0.00",
							"pay_price": "23.00"
						}],
						"need_address": 1,
						"activity_discount_infos": [],
						"msg": null
					}
				}

				that.orderPre = res.data;
				that.perGoodsList = res.data.new_goods_list;
				that.totalNum = 0;
				that.perGoodsList.map(item => {
					item.selType = item.dispatch_type;
					that.totalNum += item.goods_num;
					that.goodsList.forEach(goods => {
						if (item.goods_id == goods.goods_id && item.sku_price_id == goods
							.sku_price_id) {
							goods.dispatch_type = item.dispatch_type;

							if (item.store_id) {
								goods.store_id = item.store_id;
							}
						}
					});
				});

				// that.$http('order.pre', {
				// 	goods_list: that.goodsList,
				// 	from: that.from,
				// 	address_id: that.addressId,
				// 	coupons_id: that.couponId,
				// 	order_type: that.orderType,
				// 	buy_type: that.grouponBuyType,
				// 	groupon_id: that.grouponId
				// }).then(res => {
				// 	if (res.data) {
				// 		that.orderPre = res.data;
				// 		that.perGoodsList = res.data.new_goods_list;
				// 		that.totalNum = 0;
				// 		that.perGoodsList.map(item => {
				// 			item.selType = item.dispatch_type;
				// 			that.totalNum += item.goods_num;
				// 			that.goodsList.forEach(goods => {
				// 				if (item.goods_id == goods.goods_id && item.sku_price_id == goods
				// 					.sku_price_id) {
				// 					goods.dispatch_type = item.dispatch_type;

				// 					if (item.store_id) {
				// 						goods.store_id = item.store_id;
				// 					}
				// 				}
				// 			});
				// 		});
				// 	}
				// });
			},
			// 提交订单
			subOrder() {
				let that = this;
				that.isDisabled = true;
				let goods = this.orderPre.orders[0]['order_goods'].map((el, index) => {
					return {
						'goods_id': el.goods_id,
						'total': el.total,
						'option_id': el.goods_option_id
					}
				})
				if(Object.keys(this.addressData).length === 0){
					uni.showToast({
						title: "请先选择地址!"
					})
					return
				}
				that.$http.post('index.threeOrderAction', {
					"address": JSON.stringify(that.addressData), //地址信息
					"call": "", //默认
					"company_number": "", //默认
					"dispatch_type_id": 1, //默认
					"goods": JSON.stringify(goods), //商品信息
					"invoice_type": 0, //默认
					"member_coupon_ids": "[]", //默认
					"option_level_id": that.oneOrderPrams.option_level_id, //规格层级id
					"orders": "[]", //默认
					"rise_type": 1, //默认
					"team_id": that.oneOrderPrams.team_id //要参团的团id
				}).then(res => {
					that.$Router.replace({
						path:  `/pages/order/payment/method`,
						query: {
							orderId: res.data.order_ids,
							goodsId: this.oneOrderPrams.team_id,
							payState: 'paying',
						}
					});
					// that.isDisabled = false;
					// if (res.code === 1) {
					// 	that.getCartList();
					// 	that.$Router.replace({
					// 		path: res.data.status > 0 ? `/pages/order/payment/result` :
					// 			`/pages/order/payment/method`,
					// 		query: {
					// 			orderId: res.data.id,
					// 			payState: res.data.status > 0 ? 'success' : 'paying'
					// 		}
					// 	});
					// }
				});
			},

			// 初始地址
			getDefaultAddress() {
				// this.addressData = {
				// 	address: "ccc",
				// 	area_id: 110101,
				// 	area_name: "东城区",
				// 	city_id: 110100,
				// 	city_name: "北京市",
				// 	consignee: "ceshi",
				// 	id: 471,
				// 	is_default: "1",
				// 	latitude: null,
				// 	longitude: null,
				// 	phone: "15382852045",
				// 	province_id: 110000,
				// 	province_name: "北京市",
				// 	user_id: 4179,
				// };
				// this.addressId = this.addressData.id;
				// this.getPre();


				this.$http.get('index.addresslist').then(res => {
					this.addressData = res.data[0];
				})
				// this.$http('address.defaults', {}, '', false).then(res => {
				// 	if (res.code === 1 && res.data) {
				// 		this.addressData = res.data;
				// 		this.addressId = res.data.id;
				// 	}
				// 	this.getPre();
				// });
			},
			//  预下单---第一步
			oneOrderAction() {
				this.$http.get('index.oneOrderAction', this.oneOrderPrams).then(res => {
					this.orderPre = res.data;
				})
			},

			// 可用优惠券
			getCoupons() {
				// let that = this;
				// that.$http('order.coupons', {
				// 	goods_list: that.goodsList,
				// 	from: that.from,
				// 	address_id: that.addressId,
				// 	coupons_id: that.couponId,
				// 	order_type: that.orderType
				// }).then(res => {
				// 	if (res.code === 1) {
				// 		that.couponList = res.data;
				// 	}
				// });
			},

			// 选择优惠券
			selectCoupon(index) {
				this.couponId = index >= 0 ? this.couponList[index].user_coupons_id : 0;
				this.getPre();
			},

			// 显示配送方式弹窗
			async onSelExpressType(goods) {
				this.showExpressType = true;
				this.inExpressType = goods.detail.dispatch_type_arr;
				this.currentGoodsId = goods.goods_id;
				this.currentSkuId = goods.sku_price_id;
				this.goodsList.forEach(item => {
					if (item.goods_id == this.currentGoodsId && this.currentSkuId == item.sku_price_id) {
						this.expressTypeCur = item.dispatch_type;
						this.selfPhone = item.dispatch_phone ? item.dispatch_phone : this.addressData && this
							.addressData.phone;
						this.checkDayCur = item.checkDayCur ? item.checkDayCur : 0;
						this.checkTimeCur = item.checkTimeCur ? item.checkTimeCur : 0;
						if (this.expressTypeCur == 'selfetch') {
							!this.lat && this.getLocation();
							this.storeList.forEach(store => {
								if (item.store_id == store.id) {
									this.storeInfo = store;
								}
							});
							this.selfPhone = item.dispatch_phone ? item.dispatch_phone : this.addressData &&
								this.addressData.phone;
						}
					}
				});
			},
			// 关闭配送方式弹窗
			hideExpressType() {
				this.showExpressType = false;
				this.changeGoodsList();
			},
			// 保存配送方式
			saveExpressType() {
				if (this.expressTypeCur === 'selfetch') {
					if (!this.storeInfo) {
						this.$u.toast('暂无自提点，请选择其他配送方式');
						return false;
					}
					if (!this.isProtocol) {
						this.$u.toast('请先勾选门店协议');
						return false;
					}
				}

				this.showExpressType = false;
				this.changeGoodsList();
				this.getPre();
			},

			// 更改提交数据
			changeGoodsList() {
				this.goodsList.forEach(goods => {
					if (goods.goods_id == this.currentGoodsId && this.currentSkuId == goods.sku_price_id) {
						goods.dispatch_type = this.expressTypeCur;
						goods.dispatch_phone = this.selfPhone;
						goods.dispatch_date = this.checkTime['day'][this.checkDayCur].value + ' ' + this.checkTime[
							'time'][this.checkTimeCur] + ':00';
						if (this.expressTypeCur == 'selfetch') {
							if (!this.storeInfo) {
								this.$u.toast('暂无自提点，请选择其他配送方式');
								return false;
							}
							goods.store_id = this.storeInfo.id;
						}
						goods.checkDayCur = this.checkDayCur;
						goods.checkTimeCur = this.checkTimeCur;
					}
				});
			},

			// 选择快递方式
			changeExpressType(cur) {
				this.expressTypeCur = cur;
				this.getFocus = false;
				cur === 'selfetch' && !this.lat && this.getLocation();
			},

			// 是否同意协议
			checkProtocol() {
				this.isProtocol = !this.isProtocol;
			},
			// 选择配送时间
			checkExpressTime(type) {
				switch (type) {
					case 'store':
						this.checkType = '配送';
						break;
					case 'selfetch':
						this.checkType = '自提';
						break;
					default:
						this.checkType = '自提';
				}
				this.showCheckTime = !this.showCheckTime;
			}
		}
	};
</script>

<style lang="scss">
	// 收货地址栏
	.head_box {
		background-color: #fff;
	}

	.add-address-box {
		min-height: 100rpx;
		background: url('http://file.shopro.top/imgs/order/order_address_line.png') no-repeat;
		background-size: 100% auto;
		background-position: bottom center;

		.select-notice {
			font-weight: 400;
			color: rgba(153, 153, 153, 1);
			line-height: 40rpx;
		}

		.name,
		.phone {
			font-size: 30rpx;
			font-weight: 500;
		}

		.phone {
			margin: 0 20rpx;
		}

		.tag {
			background: rgba(233, 191, 113, 0.2);
			border-radius: 6rpx;
			padding: 0 16rpx;
			line-height: 38rpx;
			color: #a8700d;
			font-size: 22rpx;
		}

		.detail {
			.address {
				margin-top: 25rpx;
				width: 543rpx;
				font-size: 26rpx;

				font-weight: 400;
				color: rgba(153, 153, 153, 1);
				line-height: 40rpx;
			}
		}
	}

	// 备注
	.remark-box {
		margin-top: 20rpx;
		background: #fff;
		padding: 25rpx;

		.item-input {
			flex: 1;
			text-align: end;
			font-size: 28rpx;
		}

		.input-pl {
			color: #c4c4c4;
		}
	}

	// 商品卡片
	.goods-list {
		background: #fff;
		margin-top: 20rpx;

		.goods-card {
			min-height: 200rpx;

			.goods-price {
				font-size: 30rpx;
				font-weight: 500;
				width: 480rpx;
				color: #333333;

				.goods-num {
					font-size: 28rpx;
					color: #c4c4c4;
				}
			}

			.order-sku {
				font-size: 24rpx;
				font-weight: 400;
				color: rgba(153, 153, 153, 1);
				width: 440rpx;
				margin-bottom: 20rpx;

				.order-num {
					margin-right: 10rpx;
				}
			}
		}
	}

	.item-list {
		height: 100rpx;
		background: #fff;
		padding: 0 25rpx;

		.item-title {
			font-size: 28rpx;
			margin-right: 20rpx;

			.activity-title {
				font-size: 26rpx;
				color: #999;
			}
		}

		.detail {
			font-size: 28rpx;
			color: #333;
		}

		.origin-price {
			font-size: 26rpx;
			color: #666;
			text-decoration: line-through;
		}

		.price {
			font-size: 26rpx;
			color: #ff0000;
			margin-right: 40rpx;
		}

		.sel-coupon {
			font-size: 26rpx;
			color: #c4c4c4;
			margin-right: 20rpx;
		}
	}

	.logistic,
	.price-box,
	.remark-box,
	.score,
	.coupon {
		border-top: 1rpx solid rgba(#dfdfdf, 0.5);
	}

	.border-top {
		border-top: 1rpx solid rgba(#dfdfdf, 0.5);
	}

	.foot-box-wrap {
		height: calc(100rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
		position: relative;
		width: 100%;
		z-index: 70;
	}

	.foot-box {
		position: fixed;
		display: flex;
		align-items: center;
		width: 100%;
		height: calc(100rpx + env(safe-area-inset-bottom) / 2);
		border-top: 1rpx solid #eeeeee;
		background-color: #fff;
		z-index: 998;
		bottom: 0;
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
		padding: 0 30rpx;

		.btn-hover {
			color: #fff;
		}

		.num {
			font-size: 26rpx;
			color: #999;
		}

		.all-money {
			margin: 0 60rpx 0 20rpx;

			.price {
				color: #ff0000;
			}
		}

		.sub-btn {
			width: 210rpx;
			line-height: 70rpx;
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
			box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
			border-radius: 50rpx;
			font-size: 28rpx;
			color: #fff;
		}
	}

	// 弹窗之配送方式
	// 配送方式
	.express-type {
		width: 750rpx;
		background-color: #fff;
		border-radius: 20rpx 20rpx 0 0;
		height: 700rpx;
		overflow: visible;

		.express-type__head {
			width: 100%;
			height: 80rpx;
			background: #f8e3bd;
			border-radius: 20rpx 20rpx 0 0;

			&-nav {
				width: (750rpx/4);
				position: relative;
				height: 100%;
			}

			.head-nav--active {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				bottom: 0;
				background: #fff;
				width: 100%;
				height: 80rpx;
				background-color: #fff;
				border-radius: 20rpx 20rpx 0px 0px;

				&::after {
					content: '';
					display: block;
					width: 40rpx;
					height: 80rpx;
					position: absolute;
					transform: skewX(20deg);
					background: #fff;
					border-top-right-radius: 20rpx;
					top: 0;
					right: -15rpx;
				}

				&::before {
					content: '';
					display: block;
					width: 40rpx;
					height: 80rpx;
					position: absolute;
					transform: skewX(-20deg);
					background: #fff;
					border-top-left-radius: 20rpx;
					top: 0;
					left: -15rpx;
				}
			}

			.head-nav__left--active {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				bottom: 0;
				background: #fff;
				width: 100%;
				height: 74rpx;
				background-color: #fff;
				border-radius: 20rpx 20rpx 0px 0px;

				&::after {
					content: '';
					display: block;
					width: 40rpx;
					height: 74rpx;
					position: absolute;
					transform: skewX(20deg);
					background: #fff;
					border-top-right-radius: 20rpx;
					top: 0;
					right: -15rpx;
				}
			}

			.head-nav__right--active {
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				bottom: 0;
				background: #fff;
				width: 100%;
				height: 74rpx;
				background-color: #fff;
				border-radius: 20rpx 20rpx 0px 0px;

				&::before {
					content: '';
					display: block;
					width: 40rpx;
					height: 74rpx;
					position: absolute;
					transform: skewX(-20deg);
					background: #fff;
					border-top-left-radius: 20rpx;
					top: 0;
					left: -15rpx;
				}
			}

			.head-nav__title {
				font-size: 24rpx;
				font-weight: 500;
				color: #666;
				position: relative;
				z-index: 6;
			}

			.head-nav__title--active {
				color: #a8700d;
				font-size: 26rpx;
			}
		}

		.express-type__content {
			.empty-address {
				height: 120rpx;
				padding: 0 25rpx;
				font-size: 28rpx;

				font-weight: 400;
				color: rgba(153, 153, 153, 1);
			}

			// 无定位
			.location-box {
				height: 500rpx;
				justify-content: center;

				.nolocation-img {
					width: 74rpx;
					height: 90rpx;
					margin-bottom: 40rpx;
				}

				.location-title {
					font-size: 35rpx;

					font-weight: bold;
					color: rgba(70, 53, 27, 1);
					margin-bottom: 20rpx;
				}

				.location-tip {
					font-size: 28rpx;

					font-weight: 400;
					color: rgba(153, 153, 153, 1);
					margin-bottom: 40rpx;
				}

				.open-location {
					width: 492rpx;
					line-height: 70rpx;
					background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
					box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
					border-radius: 35rpx;
					font-size: 28rpx;

					font-weight: 500;
					color: rgba(255, 255, 255, 1);
				}
			}

			// 快递
			.express-address {
				position: relative;
				padding: 30rpx 25rpx;
				background: url('http://file.shopro.top/imgs/order/address_bg.png') no-repeat;
				background-size: 430rpx 300rpx;
				background-position: top right;

				.express-top {
					margin-bottom: 20rpx;
					width: 550rpx;
					text-align: left;

					.address {
						font-size: 28rpx;
						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						line-height: 40rpx;
						text-align: left;
					}

					.dispatch-notice {
						font-size: 28rpx;

						font-weight: 500;
						color: rgba(51, 51, 51, 1);
						line-height: 40rpx;
						text-align: left;
					}

					.address-location {
						position: absolute;
						right: 60rpx;
						top: 30rpx;

						.location-img {
							width: 80rpx;
							height: 90rpx;
						}

						.location-text {
							font-size: 18rpx;

							font-weight: 500;
							color: rgba(51, 51, 51, 1);
						}
					}

					.tag {
						background: rgba(233, 191, 113, 0.2);
						border-radius: 6rpx;
						padding: 0 16rpx;
						line-height: 38rpx;
						color: #a8700d;
						font-size: 22rpx;
						margin-right: 20rpx;
					}

					.tag1 {
						background: rgba(53, 190, 105, 0.2);
						border-radius: 6rpx;
						padding: 0 16rpx;
						line-height: 38rpx;
						color: #1bbc50;
						font-size: 22rpx;
						margin-right: 20rpx;
					}

					.address-guide {
						position: absolute;
						right: 25rpx;
						top: 40rpx;
						color: #999999;
					}
				}

				.express-content {
					margin-bottom: 20rpx;

					.box-line {
						width: 1rpx;
						height: 61rpx;
						border-left: 1rpx solid rgba(238, 238, 238, 1);
						margin: 0 40rpx;
					}

					.phone-box1 {

						.name,
						.phone {
							font-size: 26rpx;

							font-weight: 400;
							color: rgba(102, 102, 102, 1);
						}

						.phone {
							margin-left: 20rpx;
						}
					}

					.time-box,
					.phone-box {
						text-align: left;
						min-height: 120rpx;

						.box-title {
							font-size: 24rpx;

							font-weight: 400;
							color: #666;
							padding-bottom: 10rpx;
						}

						.box-text {
							font-size: 24rpx;

							font-weight: 500;
							color: #333;
						}

						.edit-phone {
							width: 160rpx;
							font-size: 24rpx;

							font-weight: 500;
							color: #333;
						}

						.box-icon {
							font-size: 28rpx;
							color: #999;
							display: inline-block;
							width: 40rpx;
							text-align: center;
							line-height: 40rpx;
						}
					}
				}

				.express-bottom {
					.protocol {
						font-size: 24rpx;

						font-weight: 400;
						color: rgba(102, 102, 102, 1);

						.protocol-text {
							color: #6487a4;
						}
					}
				}
			}
		}

		.express-type__bottom {
			height: 90rpx;
			padding: 0 30rpx;

			.cancel-btn {
				width: 335rpx;
				line-height: 74rpx;
				background: rgba(238, 238, 238, 1);
				border-radius: 37rpx;
				font-size: 28rpx;

				font-weight: 400;
				color: rgba(51, 51, 51, 1);
			}

			.save-btn {
				width: 335rpx;
				line-height: 74rpx;
				background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
				border-radius: 37rpx;
				font-size: 28rpx;

				font-weight: 400;
				color: rgba(255, 255, 255, 1);
			}
		}
	}

	// 选择配送给时间
	.checkTime-box {
		background: rgba(255, 255, 255, 1);
		border-radius: 20rpx 20rpx 0px 0px;
		height: 720rpx;
		text-align: center;

		.checkTime-head {
			font-size: 32rpx;

			font-weight: 500;
			color: rgba(51, 51, 51, 1);
			line-height: 100rpx;
			position: relative;
		}

		.checkTime-foot {
			height: 100rpx;

			.save-btn {
				width: 690rpx;
				line-height: 80rpx;
				background: linear-gradient(90deg, rgba(240, 199, 133, 1), rgba(246, 214, 157, 1));
				border-radius: 40rpx;
				font-size: 30rpx;

				font-weight: 500;
				color: rgba(255, 255, 255, 1);
			}
		}

		.checkTime-content {
			.checkTime-content__left {
				height: 100%;
				width: 190rpx;
				background: #f5f5f5;

				.left-item {
					font-size: 26rpx;

					font-weight: 500;
					color: rgba(51, 51, 51, 1);
					height: 100rpx;
					width: 100%;
				}
			}

			.checkTime-content__right {
				flex: 1;
				height: 100%;
				overflow-y: auto;

				.right-item {
					font-size: 26rpx;

					font-weight: 500;
					color: rgba(51, 51, 51, 1);
					width: 100%;
					text-align: center;
					border-bottom: 1rpx solid rgba(#dfdfdf, 0.6);
					margin: 0 30rpx;
					line-height: 100rpx;
				}
			}

			.item--active {
				font-size: 26rpx;

				font-weight: 500;
				color: rgba(168, 112, 13, 1) !important;
				background-color: #fff;
			}
		}
	}
</style>

<style lang="scss" scoped>
	@import './confirm.scss';
</style>
